﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Backend.JYD.Model.Cust;
using Backend.JYD.Model;

namespace Backend.JYD.BLL
{
    public class CustMarketingInfoBLL
    {
        private static readonly IDAL.Cust.ICustMarketingInfo idal = Factory.DALFactory.CreateEFDAL<IDAL.Cust.ICustMarketingInfo>("DAL.CustMarketingInfoDAL");


        public Int64 AddCustMarketingInfo(CustMarketingInfo info)
        {
            if (string.IsNullOrWhiteSpace(info.CustName)) return 0;
            if (!info.ScheduleTime.HasValue || info.ScheduleTime.Value < DateTime.Today) return 0;
            return idal.AddCustMarketingInfo(info);
        }

        public bool UpdateCustMarketingInfo(CustMarketingInfo info)
        {
            if (info.MarketingId <= 0) return false;
            return idal.UpdateCustMarketingInfo(info);
        }

        public List<CustMarketingInfo> GetCustMarketingInfoByEmpId(Int64 empId)
        {
            if (empId <= 0) return null;
            var list = idal.GetCustMarketingInfoByEmpId(empId);
            return list == null ? null : list.ToList();
        }

        public PageInfo<CustMarketingInfo> GetCustMarketingInfoByPage(Int64? empId, DateTime? start, DateTime? end, int? status, PageInfo page)
        {
            if (empId <= 0) return null;
            return idal.GetCustMarketingInfoByPage(empId, start, end, status, page);
        }

        public CustMarketingInfo GetCustMarketingInfoByMarketingId(Int64 empId, Int64 marketingId)
        {
            if (marketingId <= 0) return null;
            return idal.GetCustMarketingInfoByMarketingId(empId, marketingId);
        }

        public List<CustMarketingInfo> GetCustMarketingInfoByTaskDetailIds(List<Int64> taskDetailIds)
        {
            if (taskDetailIds != null || taskDetailIds.Count <= 0) return null;
            var list = idal.GetCustMarketingInfoByTaskDetailIds(taskDetailIds);
            return list == null ? null : list.ToList();
        }
        public CustMarketingInfo GetCustMarketingInfoByTaskDetailId(Int64? taskId, Int64 taskDetailId)
        {
            if (taskId.HasValue && taskId.Value <= 0) return null;
            if (taskDetailId <= 0) return null;
            return idal.GetCustMarketingInfoByTaskDetailId(taskId, taskDetailId);
        }

        public PageInfo<CustBase> SearchCustBaseInfo(PageInfo page, string name, string phone)
        {
            return idal.SearchCustBaseInfo(page, name, phone);
        }

    }
}
